var app = getApp()
var db = wx.cloud.database()
Page({

    data: {
        nav: [{
                url: "/pages/home/pizza/pizza",
                id: "0",
                title: "鹿家Pizza",
                icon: "/images/pizza.png"
            },
            {
                url: "/pages/home/pizza/pizza",
                id: "1",
                title: "鹿家正餐",
                icon: "/images/food.png"
            },
            {
                url: "/pages/home/pizza/pizza",
                id: "2",
                title: "鹿家饮品",
                icon: "/images/drink.png"
            },
        ]

    },


    onLoad: function(options) {
        let that = this;
        let winh = app.globalData.winH;
        let tabbar = app.globalData.tabbar;
        let date = new Date();
        let week = date.getDay(); //星期
        let nowday = date.getDate();
        let moonth = date.getMonth() + 1;

        that.setData({
            winh: winh,
            moonth: moonth,
            nowday: nowday,
            week: week,
            tabbar: tabbar
        })
    },
    onReady: function() {
        let that = this;
        db.collection('index_banner').where({}).get({
            success: function(res) {
                console.log(res)
                that.setData({
                    banner: res.data
                })
            }
        })
        db.collection('recommend').get().then(res => {
            console.log(res.data)
            that.setData({
                recommend:res.data
            })
        })
        db.collection('environment').get().then(res => {
            console.log(res.data)
            that.setData({
                environment: res.data
            })
        })

        
        

    },
    onShow: function() {
        // let that = this;
        // let userinfo = wx.getStorageSync("userInfo");
        // if (userinfo == "") {
        //     wx.navigateTo({
        //         url: '/pages/home/login/login',
        //     })
        // }
        // that.setData({
        //     userinfo: userinfo
        // })
        
    },
    onHide: function() {

    },
    onUnload: function() {

    },
    onPullDownRefresh: function() {

    },
    onReachBottom: function() {

    },
    onShareAppMessage: function() {

    }
})